from django.test import TestCase

from users.models import User
from tasks.models import Tasks


class UserTestClass(TestCase):
        
    def setUp(self):
        users_count = 19
        for number in range(users_count):
            user = User.objects.create(email=f'user_{number + 1}@email.moc')

        self.user_1 = User.objects.get(id=1)
        self.user_2 = User.objects.get(id=2)

    def test_users_count(self):
        users = User.objects.all()
        self.assertEquals(users.count(), 19)

    def test_user_default_boolean_values(self):
        self.assertTrue(self.user_1.send_message)
        self.assertFalse(self.user_2.is_activated)

    def test_user_create_username(self):
        self.user_1.username = self.user_1.email.split('@')[0]
        self.user_1.save()
        self.assertEqual(self.user_1.username, 'user_1')